<form class="layui-form" action="{{ request.uri }}" method="post" id="editForm">
    {% raw xsrf_form_html() %}
    <input type="hidden" name="rsa_encrypt" value="{{ rsa_encrypt }}">
    <input type="hidden" name="id" value="{{ user.id }}">
    <div class="layui-tab" style="margin: 1em;">
        <ul class="layui-tab-title">
            <li class="layui-this">基本信息</li>
            <li>权限分配</li>
        </ul>
        <div class="layui-tab-content">
            <div class="layui-tab-item layui-show">
                <div class="layui-form-item">
                    <label class="layui-form-label">角色分组</label>
                    <div class="layui-input-block">
                        <select name="role_id" class="field-role_id" type="select">
                            {% raw role_option %}
                        </select>
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">用户名</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input field-username" name="username" value="{{ user.username }}" lay-verify="required" autocomplete="off" placeholder="请输入用户名">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">登陆密码</label>
                    <div class="layui-input-block">
                        <input type="password" class="layui-input" name="password" lay-verify="password" autocomplete="off" placeholder="******">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">联系邮箱</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input field-email" name="email" value="{{ user.email }}" lay-verify="" autocomplete="off" placeholder="请输入邮箱地址">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">联系手机</label>
                    <div class="layui-input-block">
                        <input type="text" class="layui-input field-mobile" name="mobile" value="{{ user.mobile }}" lay-verify="" autocomplete="off" placeholder="请输入手机号码">
                    </div>
                </div>
                <div class="layui-form-item">
                    <label class="layui-form-label">状&nbsp;&nbsp;&nbsp;&nbsp;态</label>
                    <div class="layui-input-block">
                        <input type="checkbox" name="status" value="1" lay-skin="switch" lay-text="启用|禁用" {% if user.status==1 %}checked{% end %}>
                    </div>
                </div>
            </div>
            <div class="layui-tab-item layui-form">
                <div class="layui-collapse page-tips">
                  <div class="layui-colla-item">
                    <h2 class="layui-colla-title">温馨提示</h2>
                    <div class="layui-colla-content layui-show">
                        <p>
                        您可以针对此用户单独设置角色分组以外的权限；优先判断“个人权限”，再次判断“角色权限”
                        </p>
                    </div>
                  </div>
                </div>
                <div class="layui-form-item role-list-form">
                    {% for v in menu_list %}
                    <dl class="role-list-form-top">
                        <dt>
                            <input type="checkbox" name="permission" value="{{ v['code'] }}" lay-filter="userPermission" data-parent="0" data-level="1" lay-skin="primary" title="{{ v['title'] }}"/>
                        </dt>
                        <dd>
                            {% for vv in v['children'] %}
                            <dl>
                                <dt>
                                    <input type="checkbox" name="permission" value="{{ vv['code'] }}" lay-filter="userPermission" data-pid="{{ vv['parent_id'] }}" data-level="2" lay-skin="primary" title="{{ vv['title'] }}">
                                </dt>
                                <dd>
                                    {% for vvv in vv['children'] %}
                                    <dl>
                                        <dt style="float: left;">
                                            <input type="checkbox" name="permission" value="{{ vvv['code'] }}" lay-filter="userPermission" data-pid="{{ vvv['parent_id'] }}" data-level="3" lay-skin="primary" title="{{ vvv['title'] }}">
                                        </dt>
                                        <dd>
                                            {% for vvvv in vvv['children'] %}
                                                <input type="checkbox" name="permission" value="{{ vvvv['code'] }}" lay-filter="userPermission" data-pid="{{ vvvv['parent_id'] }}" data-level="4" lay-skin="primary" title="{{ vvvv['title'] }}">
                                            {% end %}
                                        </dd>
                                    </dl>
                                    {% end %}
                                </dd>
                            </dl>
                            {% end %}
                        </dd>
                    </dl>
                {% end %}
                </div>
            </div>
        </div>
    </div>
    <div style="position:fixed; bottom:0; background: #fff; width: 100%; height: 3.2em; text-align: center;">
        <button type="submit" class="layui-btn" lay-submit="" lay-filter="formSubmit">提交</button>
        <button type="reset" class="layui-btn layui-btn-primary">重置</button>
    </div>
</form>
<script type="text/javascript">
var rsa_encrypt = '{{ rsa_encrypt }}'
var public_key = '{{ public_key.replace('\n', '')[26:-24] }}'
var formData = {% raw data_info %}

$( document ).ready(function() {
    set_form_data(formData)
});
</script>